package info.zlong.visibleruntime.core;

public class LoggerUtil {
    private static ThreadLocal<LogMsgHolder> localLogMsg = new ThreadLocal<LogMsgHolder>();
    

    public static void initLogMsgId(String id) {
    	LogMsgHolder logMsg = getHolder();
		
		logMsg.setId(id);
    }

	private static LogMsgHolder getHolder() {
		LogMsgHolder logMsg = localLogMsg.get();
		if (logMsg == null) {
			
        	logMsg = new LogMsgHolder();
			localLogMsg.set(logMsg);
        }
		return logMsg;
	}
    
    public static String log(String msg){
    	return log(null,msg);
    }
    
    public static String log(String key,String msg){
    	LogMsgHolder holder = getHolder();
    	
    	return holder.getLog(key, msg);
    }
    
    public static String startLog(String key,String msg){
    	LogMsgHolder holder = getHolder();
    	
    	return holder.getStartLog(key, msg);
    }
    
    public static String endLog(String msg){
    	return endLog(null,msg);
    }
        
    public static String endLog(String key,String msg){
    	LogMsgHolder holder = getHolder();
    	
    	return holder.getEndLog(key, msg);
    }

}
